/**
 ******************************************************************************
 * @file           : bsp_spi_config.h
 * @brief          : SPI Configuration File (STM32H7xx)
 ******************************************************************************
 * @attention
 *
 * SPI配置文件
 * 支持SPI1~SPI6
 *
 ******************************************************************************
 */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __BSP_SPI_CONFIG_H
#define __BSP_SPI_CONFIG_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx.h"

/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/

/* ============================================================================ */
/*                       日志系统配置（改这里的数字）                             */
/* ============================================================================ */
#define SPI_USE_LOG     1

#if (SPI_USE_LOG == 1)
    #ifndef LOG_TAG
        #define LOG_TAG    "SPI"
    #endif
    #include "elog.h"
#elif (SPI_USE_LOG == 2)
    #include <stdio.h>
    #define log_i(fmt, ...)     printf(fmt "\r\n", ##__VA_ARGS__)
    #define log_w(fmt, ...)     printf("[WARN] " fmt "\r\n", ##__VA_ARGS__)
    #define log_e(fmt, ...)     printf("[ERROR] " fmt "\r\n", ##__VA_ARGS__)
    #define log_d(fmt, ...)     printf("[DEBUG] " fmt "\r\n", ##__VA_ARGS__)
#else
    #define log_i(fmt, ...)
    #define log_w(fmt, ...)
    #define log_e(fmt, ...)
    #define log_d(fmt, ...)
#endif

/* ============================================================================ */
/*                      SPI配置                                               */
/* ============================================================================ */

#define SPI_SELECT_NUM      1           /* 使用SPI1 */
#define SPI_CLK_GPIO_PORT   GPIOA
#define SPI_CLK_GPIO_PIN    GPIO_PIN_5
#define SPI_MOSI_GPIO_PORT  GPIOA
#define SPI_MOSI_GPIO_PIN   GPIO_PIN_7
#define SPI_MISO_GPIO_PORT  GPIOA
#define SPI_MISO_GPIO_PIN   GPIO_PIN_6
#define SPI_GPIO_AF         GPIO_AF5_SPI1

/* Exported macro ------------------------------------------------------------*/
/* Exported variables --------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/

#ifdef __cplusplus
}
#endif

#endif /* __BSP_SPI_CONFIG_H */
